{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "03dace38",
   "metadata": {},
   "outputs": [],
   "source": [
    "from transformers import AutoTokenizer, DebertaV2Model\n",
    "from modeling import DebertaV3ForPreTraining, DebertaV2ForReplacedTokenDetection\n",
    "from transformers.trainer_utils import get_last_checkpoint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cbdb5d70",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'debertav3-small/checkpoint-38000'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "latest = get_last_checkpoint(\"debertav3-small\")\n",
    "latest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9c547594",
   "metadata": {},
   "outputs": [],
   "source": [
    "model = DebertaV2Model.from_pretrained(latest)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "22586faa",
   "metadata": {},
   "outputs": [],
   "source": [
    "tokenizer = AutoTokenizer.from_pretrained(latest)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "59c3ace0",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/ubuntu/.local/lib/python3.10/site-packages/transformers/utils/hub.py:700: UserWarning: The `organization` argument is deprecated and will be removed in v5 of Transformers. Set your organization directly in the `repo_id` passed instead (`repo_id={organization}/{model_id}`).\n",
      "  warnings.warn(\n"
     ]
    }
   ],
   "source": [
    "tokenizer.push_to_hub('malaysian-debertav3-small', organization='mesolitica')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3e93db33",
   "metadata": {},
   "outputs": [],
   "source": [
    "model.push_to_hub('malaysian-debertav3-small', organization='mesolitica')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
